// OGoMojo
// Whitemice.MOGI.RPC2.Project
// License: LGPL
// Copyright: Whitemice Consulting, 2006
// Author(s): Adam Tauno Williams (awilliam@whitemice.org)
using System;
using System.Globalization;
using Whitemice.MOGI;
using CookComputing.XmlRpc;

namespace Whitemice.MOGI.RPC2 {
	/// \brief Implementation of IProject
	public class Project : Whitemice.MOGI.RPC2.Document, IProject {
		/// \brief Constructor
		/// \param document An XmlRpcStruct document
		/// \param server Reference to server object	
		public Project (XmlRpcStruct document, Server server)
		 : base(document, server) {
		}
		
		/// \brief Returns the unique name of the object
		public override string Name {
			get {
				return ("Document/Project/" + Number);
			}
		}
		
		/// \brief Accessor for the number value
		public new string Number { 
			get {
				return (string)document["number"];
			} 
			set {
				document["number"] = value;
			}
		}
		
		/// \brief Accessor for the startDate value
		public DateTime Start {
			get {
				string startDate = document["startDate"].ToString();
		  		startDate = startDate.Substring(0, startDate.IndexOf(' '));
		  		return DateTime.ParseExact(startDate, "M/d/yyyy", new DateTimeFormatInfo());				
			}
		}
		
		/// \brief Accessor for the endDate value
		public DateTime End {
			get {
				string startDate = document["endDate"].ToString();
		  		startDate = startDate.Substring(0, startDate.IndexOf(' '));
		  		return DateTime.ParseExact(startDate, "M/d/yyyy", new DateTimeFormatInfo());			
			}
		}
		
		/// \brief Accessor for the name value
		public string Description { 
			get {
				return (string)document["name"];
			}
			set {
				document["name"] = value;
			}
		}		
	}
}